def is_valid_sequence(sequence):
    stack = []
    mapping = {')': '(', '}': '{', ']': '[', '>': '<'}
    
    for char in sequence:
        if char in '({[<':
            stack.append(char)
        elif char in ')}]>':
            if not stack or mapping[char] != stack.pop():
                return False
    
    return not stack

brackets_sequence = "lheujq rkl"  # Измените эту строку на вашу скобочную последовательность

print(is_valid_sequence(brackets_sequence))
